<?php

namespace Portal\Model;
use Think\Model;
class PayModel extends Model {


  /**
 * Pay模型
 * @author
 */

 public function getPayPram($payCode)
 {
   $payCode = $payCode?$payCode:I("payCode");
   $Pay = M("payconfig");  //实例化模型
   $where['payCode']=$payCode;  //拼写where条件，取支付类型
   $where['enabled']=1;
   $payment = $Pay->where($where)->find();
   $payConfig = json_decode($payment["payConfig"]) ;
		foreach ($payConfig as $key => $value) {
			$payment[$key] = $value;
		}
		return $payment;
 }
 public function getPayModes()
 {
 $Pay = M("payconfig");  //实例化模型
  $where['enabled']=1;
  $data = $Pay->where($where)->field("payId,payCode,payName,images")->select();
  return $data;
 }
 public function complatePay($obj)
 {
  $where['OrderID']=$OrderID;
  $data['PayStatus']=2;  //设置状态为完成
  $data['completetime']=$obj['completetime'];  //取更新完成时间
  $data['OutSideId']=$obj['OutSideId'];   //更新第三方业务流水号
  $data['totalfee']=$obj['totalfee'];   //更新第三方金额

  $pay = M("Pay");
  $result = $pay->where($where)->save($data);




 }
 public function UpdatePay($OrderID,$obj)
 {
 	$where['OrderID']=$OrderID;
 	$pay = M("orders");
 	$result = $pay->where($where)->save($obj);
 	return $result;



 }


}